
#delimit;
capture log close;
set more off;
pause on;
clear all;

cap cd "/Users/deandulay/Dropbox/Myanmar_JOP_EGI_replication";
cap cd "C:\Users\ejm5\Dropbox\Myanmar_JOP_EGI_replication";

use "data\20200419_mbei_panel_final.dta", clear;

#delimit;
/**************************************************************INDEX Creation****************************************************************************/
#delimit;
egen DAO_indicators_soft=rowmean(rescale_q25 rescale_q72  rescale_t_q143_4 rescale_t_q46_1_binary rescale_q47 rescale_t_q112_5_binary
rescale_t_q71_3_binary rescale_t_q71_4_binary rescale_t_q71_5_binary rescale_q72); 
replace DAO_indicators_soft=DAO_indicators_soft*.6;
lab var DAO_indicators_soft "Index with Only DAO Survey Indicators";

#delimit;
egen DAO_indicators_hard=rowmean(rescale_DAO_summ_required_docs rescale_DAO_helpfulstaff rescale_DAO_pct_info_posted); 
replace DAO_indicators_hard=DAO_indicators_hard*.4;
lab var DAO_indicators_hard "Index with Only DAO Hard Indicators";

gen DAO_indicators_final=DAO_indicators_soft+DAO_indicators_hard;
lab var DAO_indicators_final "Index with Only DAO Indicators";

#delimit;
egen GAD_indicators_soft=rowmean(rescale_q38_binary rescale_q39_binary rescale_q36a_r1 rescale_t_q143_1 rescale_q33_a rescale_q43_1_binary rescale_t_q112_7_binary rescale_q130 rescale_q130_2); 
replace GAD_indicators_soft=GAD_indicators_soft*.6;
lab var GAD_indicators_soft "Index with Only GAD Survey Indicators";

#delimit;
egen GAD_indicators_hard=rowmean(rescale_GAD_pct_info_posted rescale_GAD_helpfulstaff rescale_crime_pc); 
replace GAD_indicators_hard=GAD_indicators_hard*.4;
lab var GAD_indicators_hard "Index with Only GAD Hard Indicators";

gen GAD_indicators_final=GAD_indicators_soft+GAD_indicators_hard;
lab var GAD_indicators_final "Index with Only GAD Indicators";

svy: mean DAO_indicators_soft DAO_indicators_hard DAO_indicators_final GAD_indicators_soft GAD_indicators_hard GAD_indicators_final;

/*********************************************************************************************************************************/
#delimit;

keep Panel_ID year DAO_indicators_soft DAO_indicators_hard DAO_indicators_final GAD_indicators_soft GAD_indicators_hard GAD_indicators_final;
xtset Panel_ID year;
save "data\20210807_mbei_panel_DAOGAD.dta", replace;
